Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Also sync content into Azure File Share and R2 buckets #745

Conversation

lemeurherve
Copy link
Member

@lemeurherve lemeurherve commented Oct 9, 2023

This PR allows synchronizing the content of updates.jenkins.io to the new Azure File Share and CloudFlare R2 buckets I've put in place for the migration of this service from the current VM to an high availability service on publick8s.

This migration will allow us to reduce our AWS cost by a third, thanks to the free outbound bandwidth of CloudFlare R2.

It will also allow us to benefit from a distributed service thanks to mirrorbits, and (later) the use of a bucket in each of the 6 regions offered by CloudFlare for its buckets: https://developers.cloudflare.com/r2/reference/data-location/#available-hints.

For this sync I'm using the aws-cli and azcopy tools now installed on trusted agent since jenkins-infra/jenkins-infra#3099

For aws-cli, it's using a non default updates-jenkins-io profile, stored in /home/jenkins/.aws on the agent.

For azcopy, it's using an account SAS token, stored manually as global credentials on trusted.ci.jenkins.io.
We're not reusing blobxfer, which authenticates with a global storage account access key, less secure than the SAS token which is restricted to a specific file share, and later only on the agent IP address. (IP restriction disabled for now, will be restored later with the workaround mentioned in jenkins-infra/azure#496)

Test job, using a copy of the content of updates.jenkins.io instead of running generate.sh script as we don't have access in this test to the 400Go cache folder:
https://trusted.ci.jenkins.io:1443/job/update_center_test_lemeurherve_helpdesk2649/job/test-update-center-pr-745/

If this sync works as expected, the previous one in the script targeting the current VM will be removed, as the flag mechanism used to optionally sync azure.updates.jenkins.io.

Ref: jenkins-infra/helpdesk#2649

Copy link
Contributor

@dduportal dduportal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

I've added a few codestyle proposal (2 are shellcheck not passing) but it's is ready to roll for me.

We need 2 other distincts reviews than mine to be sure we do not miss anything

site/publish.sh Outdated Show resolved Hide resolved
site/publish.sh Outdated Show resolved Hide resolved
site/publish.sh Outdated Show resolved Hide resolved
site/publish.sh Outdated Show resolved Hide resolved
@daniel-beck daniel-beck changed the title feat(udpates.jenkins.io): also sync content into Azure File Share and R2 buckets Also sync content into Azure File Share and R2 buckets Oct 9, 2023
@lemeurherve lemeurherve requested a review from timja October 9, 2023 14:41
site/publish.sh Outdated Show resolved Hide resolved
@lemeurherve lemeurherve marked this pull request as draft October 9, 2023 15:43
@lemeurherve
Copy link
Member Author

Putting the PR in draft while working on the following error:

Failed with error service level URLs (https://updatesjenkinsio.file.core.windows.net) are not supported in sync:

@lemeurherve
Copy link
Member Author

lemeurherve commented Oct 9, 2023

Found the culprit!

https://updatesjenkinsio.file.core.windows.net/: service level URL, not working.

https://updatesjenkinsio.file.core.windows.net/updates-jenkins-io: file share URL, working as intended.

I'm updating the corresponding credentials on trusted.ci.jenkins.io, and will put the PR in ready for review afterward.

site/publish.sh Outdated Show resolved Hide resolved
@lemeurherve
Copy link
Member Author

Work in progress on this branch for now: https://github.com/jenkins-infra/update-center2/blob/pr-745/site/publish.sh

I'll report the changes here when the tests will be conclusive.

@smerle33
Copy link
Contributor

smerle33 commented Oct 25, 2023

we now need to launch a mirrorbits scan ID or mirrorbits scan -all (Scan all mirrors at once) through kubectl to trigger a scan after rsync/azsync/awssync

@dduportal
Copy link
Contributor

we now need to launch a mirrorbits scan ID or mirrorbits scan -all (Scan all mirrors at once) through kubectl to trigger a scan after rsync/azsync/awssync

Update: kubectl is now installed

@lemeurherve lemeurherve force-pushed the helpdesk2649-upload-to-azure-updates-jenkins-io branch 2 times, most recently from ae75b1a to 11b661c Compare November 17, 2023 13:13
site/publish.sh Outdated Show resolved Hide resolved
site/publish.sh Outdated Show resolved Hide resolved
site/publish.sh Outdated Show resolved Hide resolved
site/publish.sh Outdated Show resolved Hide resolved
@lemeurherve lemeurherve force-pushed the helpdesk2649-upload-to-azure-updates-jenkins-io branch 2 times, most recently from a6d9a3f to c9f636a Compare November 17, 2023 15:01
site/publish.sh Outdated Show resolved Hide resolved
site/publish.sh Outdated Show resolved Hide resolved
@lemeurherve lemeurherve force-pushed the helpdesk2649-upload-to-azure-updates-jenkins-io branch from 7a7348c to ec5cc0c Compare November 20, 2023 13:58
@lemeurherve lemeurherve force-pushed the helpdesk2649-upload-to-azure-updates-jenkins-io branch from ec5cc0c to 2822a48 Compare November 20, 2023 14:02
Co-authored-by: Damien Duportal <damien.duportal@gmail.com>
@lemeurherve lemeurherve force-pushed the helpdesk2649-upload-to-azure-updates-jenkins-io branch from 2822a48 to f3c6819 Compare November 20, 2023 14:40
@lemeurherve lemeurherve marked this pull request as ready for review November 20, 2023 15:03
@lemeurherve
Copy link
Member Author

@daniel-beck @Wadeck @MarkEWaite @timja this PR is ready for review.

I've put every new operations behind an opt-in flag, to be set to optin as env var on the job to sync both updates.jenkins.io and azure.updates.jenkins.io.

After approval and before merging, we intend to make a backup of updates.jenkins.io JSONs from pkg.origin.jenkins.io VM (maybe a daily one), and a snapshot of the disk where the update-center2 job cache is stored.

@lemeurherve
Copy link
Member Author

lemeurherve commented Jan 25, 2024

The only change expected to this PR is the addition of an az login with a service principal followed by an az storage share generate-sas so the SAS token used to manipulate the file share will be short lived and revocable.

Ref:

Related:

@daniel-beck daniel-beck added the wrapper PR affects wrapper behavior and will be effective immediately when merged. label Mar 7, 2024
@lemeurherve
Copy link
Member Author

lemeurherve commented Mar 7, 2024

The only change expected to this PR is the addition of an az login with a service principal followed by an az storage share generate-sas so the SAS token used to manipulate the file share will be short lived and revocable.

The change will be similar to jenkins-infra/crawler#144, tested on trusted.ci.jenkins.io with our PoC job in the pr-745 branch:

# shellcheck source=/dev/null
fileShareSignedUrl=$(source ./site/get-fileshare-signed-url.sh)
# Sync Azure File Share content using www3 to avoid symlinks
time azcopy sync "${ROOT_FOLDER}/www3/" "${fileShareSignedUrl}" \

https://trusted.ci.jenkins.io:1443/job/update_center_test_lemeurherve_helpdesk2649/job/test-update-center-pr-745/153/console

Sourcing the script won't be needed with jenkins-infra/jenkins-infra#3323 as it will be directly executable from /usr/local/bin, in the $PATH.

I'm waiting for jenkins-infra/jenkins-infra#3323 to be approved and merged before pushing it here so this PR remains valid in the mean time.

@lemeurherve
Copy link
Member Author

I'm waiting for jenkins-infra/jenkins-infra#3323 to be approved and merged before pushing it here so this PR remains valid in the mean time.

Corresponding change pushed: ebfac65

I need to add an AzureServicePrincipal credentials to the update-center2 freestyle job, with the expected environment variable names like https://github.com/jenkins-infra/crawler/blob/a846b4e4ef7088f732c25e369ef56ab05bf1e77e/Jenkinsfile#L74-L77

I've also fixed the kubectl call by updating mirrorbits pod name pattern in 6261823

@lemeurherve
Copy link
Member Author

I need to add an AzureServicePrincipal credentials to the update-center2 freestyle job, with the expected environment variable names like https://github.com/jenkins-infra/crawler/blob/a846b4e4ef7088f732c25e369ef56ab05bf1e77e/Jenkinsfile#L74-L77

Credentials configured in update_center job on trusted.ci.jenkins.io.

This pull request is complete and mergeable, ready for review.

@daniel-beck daniel-beck merged commit 82c4045 into jenkins-infra:master Mar 12, 2024
2 checks passed
@lemeurherve lemeurherve deleted the helpdesk2649-upload-to-azure-updates-jenkins-io branch March 12, 2024 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wrapper PR affects wrapper behavior and will be effective immediately when merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants